| Conditions | 4 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {PollConfig} from './interfaces'; |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Split string/message to topic and choice |
||
| 5 | * reference: https://stackoverflow.com/a/18647776/2671470 |
||
| 6 | * |
||
| 7 | * @param {string} message - the new option name |
||
| 8 | * @returns {array} card |
||
| 9 | */ |
||
| 10 | export function splitMessage(message: string) { |
||
| 11 | const expression = /[^\s"]+|"([^"]*)"/gi; |
||
| 12 | const result = []; |
||
| 13 | let match; |
||
| 14 | do { |
||
| 15 | match = expression.exec(message); |
||
| 16 | if (match != null) { |
||
| 17 | result.push(match[1] ? match[1] : match[0]); |
||
| 18 | } |
||
| 19 | } while (match != null); |
||
| 20 | |||
| 21 | return result; |
||
| 22 | } |
||
| 43 |